<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>

<html>
    <head>
        <meta charset="utf-8">
        <title>修改商品</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="layui/css/layui.css" media="all">
        <%--<link rel="stylesheet" href="/css/public.css" media="all">--%>
        <style>
            body {
                background-color: #ffffff;
            }
        </style>
    </head>
    <body>
        <div class="layui-form layuimini-form">
            <input type="hidden" name="c_id"   value="${Commodity.c_id}">

            <div class="layui-form-item">
                <label class="layui-form-label required">商品名称</label>
                <div class="layui-input-block">
                    <input type="text" name="c_name" lay-verify="required"  value="${Commodity.c_name}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">商品价格</label>
                <div class="layui-input-block">
                    <input type="text" name="c_price" lay-verify="required"value="${Commodity.c_price}"  class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">商品类型</label>
                <div class="layui-input-block">
                    <input type="text" name="c_type" lay-verify="required" value="${Commodity.c_type}"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">商品销量</label>
                <div class="layui-input-block">
                    <input type="text" name="c_sales" lay-verify="required" value="${Commodity.c_sales}"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">商品库存</label>
                <div class="layui-input-block">
                    <input type="text" name="c_stock"  value="${Commodity.c_stock}"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认修改</button>
                </div>
            </div>
        </div>
        <script src="layui/layui.js" charset="utf-8"></script>
        <script>
            layui.use(['form','laydate'], function () {
                var form = layui.form,
                    layer = layui.layer,
                    laydate=layui.laydate,
                    $ = layui.$;

                //监听提交
                form.on('submit(saveBtn)', function (data) {
                    var datas=data.field;//form单中的数据信息
                    //向后台发送数据提交添加
                    $.ajax({
                        url:"/updateCommodity",
                        type:"POST",
                        data:datas,
                        success:function(result){
                            if(result.code==0){//如果成功
                                layer.msg('修改成功',{
                                    icon:6,
                                    time:500
                                },function(){
                                    parent.window.location.reload();
                                    var iframeIndex = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(iframeIndex);
                                })
                            }else{
                                layer.msg("修改失败");
                            }
                        }
                    })
                    return false;
                });
            });
        </script>
    </body>
</html>